<style>
.weui_btn {
	border-radius: 1rem;
}
.fui-picturew .item .image {
	width:100%;
    height:5.6rem;
}
.fui-picturew .item img {
    width: 100%;
    height: 100%;
}
.fui-picturew .item .image .input {
    position: absolute;
    top: 0;
    left: 0;
}
.pagination {
	display:inline-block;
	padding-left:0;
	margin:0.3rem 0;
	border-radius:4px
}
.fui-tab-scroll .item {margin-right:0.2rem}
.fui-header:after {
	border-bottom: 0 solid #D9D9D9;
}
.jylabel {
    border-radius: 1rem;
}
</style>
<div class="fui-page" style="position:static;height:auto;min-height:22rem;border-radius:0.2rem;background:#fff">
	<div class="fui-tab fui-tab-danger" style="margin-bottom:0;border-radius:0.2rem">
		<a ng-repeat="tab in modaldata.tabs" ng-show="tab.op!='remote'" ng-class="{'external active':modaldata.op==tab.op}" href="javascript:;" ng-click="modaldata.op=tab.op">{{tab.title}}</a>
	</div>
	<div ng-show="modaldata.op=='local'">
		<div class="fui-cell-group" style="margin-top:0">
		<div class="fui-cell" style="padding:1rem 4rem">
			<div ng-if="modaldata.type!='more'" class="fui-cell-info text-center">
				<img ng-if="modaldata.image && modaldata.source_type=='image'" style="width:6rem;height:6rem;" ng-src="{{tomedia(modaldata.image)}}"/>
				<video ng-if="modaldata.image && modaldata.source_type=='video'" ng-poster="{{tomedia(modaldata.thumb)}}"  height="120" width="100%" style="background:#333" controls="" x5-playsinline="" playsinline="" webkit-playsinline="" preload="auto">
					<source ng-src="{{tomedia(modaldata.image)}}" type="video/mp4">
				</video>
				<div ng-if="modaldata.source_type!='video'" ng-click="up_file(modaldata,'image',modaldata.source_type)" style="margin-top:0.5rem;border: 1px dashed #e7e7eb;height:9rem;padding:1.5rem 0.1rem;text-align:center;">
					<i class="icon icon-tianjia" style="font-size:3rem"></i>
					<div style="">{{modaldata.image?'换一个':'添加一个新的'+modaldata.typename}}</div>
				</div>
				<div ng-if="modaldata.source_type =='video'" ng-click="up_file(modaldata,['image','thumb'],modaldata.source_type)" style="margin-top:0.5rem;border: 1px dashed #e7e7eb;height:9rem;padding:1.5rem 0.1rem;text-align:center;">
					<i class="icon icon-tianjia" style="font-size:3rem"></i>
					<div style="">{{modaldata.image?'换一个':'添加一个新的'+modaldata.typename}}</div>
				</div>
			</div>
			<div ng-if="modaldata.type=='more'" ng-init="modaldata.image_list=[]" class="fui-cell-info text-center">
				<div ng-repeat="image in modaldata.image_list">
					<img style="width:3rem;height:3rem;" ng-src="{{tomedia(image) || '../core/resource/images/nopic.jpg'}}"/>
					<em class="close" title="删除这素材" ng-click="modaldata.image_list.splice($index,1)">×</em>
				</div>
				<div ng-click="up_file(modaldata,'image_list',modaldata.source_type,true)" style="margin-top:0.5rem;border: 1px dashed #e7e7eb;height:9rem;padding:1.5rem 0;text-align:center;">
					<i class="icon icon-tianjia" style="font-size:3rem"></i>
					<div style="">添加一个新的{{modaldata.typename||'素材'}}</div>
				</div>
			</div>
		</div>
		</div>
	</div>
	<div ng-show="modaldata.op=='srcurl'"  style="margin-top:0">
		<div class="weui_cells" style="min-height:12rem;padding:0.5rem">
		<div class="weui_cell weui_cells_form">
			<div class="weui_cell_hd bold"><label ng-class="{'weui_label':1,'must':{must}}">远程地址</label></div>
		</div>
		<div class="weui_cell weui_cells_form">
			<div class="weui_cell_bd weui_cell_primary">
				<input class="weui_input" type="text" style="background:#f2f2f2" ng-model="modaldata.url" placeholder="请粘贴远程地址">
			</div>
		</div>
		</div>
	</div>
	<div ng-show="modaldata.op=='list'">
		<div class="fui-header" style="top:2.3rem;background:none">
			<div class="fui-header-input" style="margin-top:0.4rem">
				<form method="post">
						<div class="searchbar searchbar-active" style="margin-left:1rem">
						<div class="search-input" style="margin-right:2.5rem">
							<i class="icon jinyunicon icon-search" style="font-size: 0.8rem;"></i>
							<input style="border-radius:1rem;background-color:#f2f2f2" type="search" id="search" ng-model="modaldata.params.title" placeholder="输入名称..." value="">
						</div>
						</div>
				</form>
			</div>
			<div class="fui-header-right" data-nomenu="true">
				<a href="javascript:;" ng-click="modaldata.params.page=1;getmodal(modal,modaldata.op,made_query(modaldata.params))" style="padding:0 0.2rem"> 搜索</a>
			</div>
		</div>
		<div class="fui-content" style="background:#fff;padding-bottom:0.5rem;border-radius:0.2rem;margin-top:1.9rem">
				<div class="fui-tab-scroll" style="padding:0.4rem;height:2.2rem">
					<div ng-repeat="group in modaldata.groups" ng-class="{'item jylabel jylabel-info-0':1,'active':modaldata.params.group_id == group.id}" style="line-height:1.8rem;padding: 0.1rem 0.6rem;" ng-click="modaldata.params.page=1;modaldata.params.group_id=group.id;getmodal(modal,modaldata.op,made_query(modaldata.params))">{{group.title}}</div>
				</div>
				<div style="padding-right:20px;" ng-include="sys_html('common/modal_page',true)"></div>
				<div ng-if="modaldata.source_type=='image' && modaldata.list.length>0" class="fui-picturew row-3" style="padding:0.3rem;height:13rem;overflow-y:scroll">
					<div ng-repeat="item in modaldata.list" class="item" style="padding: 5px;">
						<div class="image" ng-click="choose_image($index)">
							<input type="checkbox" class="input fui fui-checkbox fui-checkbox-danger verify-checkbox" ng-checked="modaldata.images.indexOf(';'+item.attachment+';')>=0">
							<img ng-src="{{tomedia(item.attachment) || '../core/resource/images/nopic.jpg'}}">
							<div class="title" style="">{{item.title}}</div>
						</div>
						
					</div>
				</div>
				<div ng-if="modaldata.source_type=='audio' && modaldata.list.length>0" class="fui-picturew row-3" style="padding:0.3rem;height:13rem;overflow-y:scroll">
					<a ng-repeat="item in modaldata.list" class="item"  style="padding: 5px;">
						<div class="image" ng-click="choose_image($index)">
							<input type="checkbox" class="input fui fui-checkbox fui-checkbox-danger verify-checkbox" ng-checked="modaldata.images.indexOf(';'+item.attachment+';')>=0">
							<i onclick="$(this).toggleClass('fa-play fa-stop');play_audio($(this).next())" class="fa fa-play"></i><audio style="display:none;" src="{{tomedia(item.attachment)}}" loop="loop"></audio>
							<div class="title" style="">{{item.title}}</div>
						</div>
					</a>
				</div>
				<div ng-if="modaldata.source_type=='video' && modaldata.list.length>0" class="fui-picturew row-3" style="padding:0.3rem;height:13rem;overflow-y:scroll">
					<a ng-repeat="item in modaldata.list" class="item"  style="padding: 5px;">
						<div class="image" ng-click="choose_image($index)" style="height:100px">
							<input type="checkbox" class="input fui fui-checkbox fui-checkbox-danger verify-checkbox" style="z-index:10000" ng-checked="modaldata.images.indexOf(';'+item.attachment+';')>=0">
							<video ng-poster="{{tomedia(item.thumb)}}" style="width:100%" height="100" controls="" x5-playsinline="" playsinline="" webkit-playsinline="" preload="auto">
								<source ng-src="{{tomedia(item.attachment)}}" type="video/mp4">
							</video>
							<div class="title">{{item.title}}</div>
						</div>
					</a>
				</div>
				<div class="content-empty" ng-show="!modaldata.list || modaldata.list.length == 0 ">
					  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">您还没有上传{{modaldata.typename||'素材'}}！</p>
					  <div class="weui_btn_area"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="modaldata.op='local'">上传{{modaldata.typename||'素材'}}</a></div>
				</div>
				<div class="weui_btn_area" ng-if="modaldata.op=='list' && modaldata.type=='more'"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="modal_result(modaldata.images)">确定</a></div>
		</div>
	</div>
	<div class="weui_btn_area" ng-if="modaldata.op=='local' && modaldata.type!='more' && modaldata.source_type!='video'"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="modal_result(modaldata.image)">确定</a></div>
	<div class="weui_btn_area" ng-if="modaldata.op=='local' && modaldata.type!='more' && modaldata.source_type=='video'"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="modal_result([modaldata.image,modaldata.thumb])">确定</a></div>
	<div class="weui_btn_area" ng-if="modaldata.op=='local' && modaldata.type=='more'"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="modaldata.modal_result(modaldata.image_list)">确定</a></div>
	<div class="weui_btn_area" ng-if="modaldata.op=='srcurl'"><a href="javascript:;" class="weui_btn weui_btn_primary" ng-click="set_srcurl(modaldata.url)">确定</a></div>
</div>
<script>
	scope.remote_up=function(url){
		var data={'url':url,'type':scope.modaldata.source_type};
		var post={'data':data,'plugin':'core','action':'tools.file_upload','op':'remote'};
		post.callback=function(res){
			scope.modal_result(res);
			scope.$evalAsync();
		}
		scope.post_json(post);
	}
	scope.modaldata.modal_result=function(images){
		var res=';'+images.join(';')+';';
		scope.modal_result(res);
	}
	scope.set_srcurl=function(url){
		if(url){
			scope.modal_result(url);
		}
	}
	scope.choose_image=function(index){
		var file=scope.modaldata.list[index].attachment;
		if(scope.modaldata.type=='more'){
			scope.duoxuans(file,scope.modaldata,'images');
		}else{
			if(scope.modaldata.source_type=='video'){
				var thumb=scope.modaldata.list[index].thumb;
				scope.modal_result([file,thumb]);
			}else{
				scope.modal_result(file);
			}
		}
	}
</script>